package com.ruoyi.cases.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cases.domain.JlQuantitativeType;
import com.ruoyi.cases.service.IJlQuantitativeTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 定额定量Controller
 * 
 * @author ruoyi
 * @date 2024-05-14
 */
@RestController
@RequestMapping("/cases/quantitativeType")
public class JlQuantitativeTypeController extends BaseController
{
    @Autowired
    private IJlQuantitativeTypeService jlQuantitativeTypeService;

    /**
     * 查询定额定量列表
     */
    @PreAuthorize("@ss.hasPermi('cases:quantitativeType:list')")
    @GetMapping("/list")
    public TableDataInfo list(JlQuantitativeType jlQuantitativeType)
    {
        startPage();
        List<JlQuantitativeType> list = jlQuantitativeTypeService.selectJlQuantitativeTypeList(jlQuantitativeType);
        return getDataTable(list);
    }

    /**
     * 导出定额定量列表
     */
    @PreAuthorize("@ss.hasPermi('cases:quantitativeType:export')")
    @Log(title = "定额定量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JlQuantitativeType jlQuantitativeType)
    {
        List<JlQuantitativeType> list = jlQuantitativeTypeService.selectJlQuantitativeTypeList(jlQuantitativeType);
        ExcelUtil<JlQuantitativeType> util = new ExcelUtil<JlQuantitativeType>(JlQuantitativeType.class);
        util.exportExcel(response, list, "定额定量数据");
    }

    /**
     * 获取定额定量详细信息
     */
    @PreAuthorize("@ss.hasPermi('cases:quantitativeType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(jlQuantitativeTypeService.selectJlQuantitativeTypeById(id));
    }

    /**
     * 新增定额定量
     */
    @PreAuthorize("@ss.hasPermi('cases:quantitativeType:add')")
    @Log(title = "定额定量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JlQuantitativeType jlQuantitativeType)
    {
        return toAjax(jlQuantitativeTypeService.insertJlQuantitativeType(jlQuantitativeType));
    }

    /**
     * 修改定额定量
     */
    @PreAuthorize("@ss.hasPermi('cases:quantitativeType:edit')")
    @Log(title = "定额定量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JlQuantitativeType jlQuantitativeType)
    {
        return toAjax(jlQuantitativeTypeService.updateJlQuantitativeType(jlQuantitativeType));
    }

    /**
     * 删除定额定量
     */
    @PreAuthorize("@ss.hasPermi('cases:quantitativeType:remove')")
    @Log(title = "定额定量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(jlQuantitativeTypeService.deleteJlQuantitativeTypeByIds(ids));
    }
}
